<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/DaoFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	/*
	* Class to select existing branches
	*/
	class CommandSelectBranches extends CustomCommand {
		/*
		 * Constructor of the class
		 */
		public function __construct() {}
		
		/*
		 * Method to execute to select existing branches
		 */
		public function execute() {
			$daoFactory = DaoFactory :: getMySqlDaoFactory();
			$ibad = $daoFactory -> getMySqlBranchAccessDao();			
				$GLOBALS['debug']->log(' INICIO Funcion COMANDO  las sucursales');
			$sentence = $ibad -> selectBranches();
			
			$branches = ''; $i = 0;
			while ($row = mysql_fetch_array($sentence)) {
				$branches['pk_rif'][$i] = $row['pk_rif'];
				$branches['name'][$i] = $row['name'];
				$branches['address'][$i++] = $row['address'];
			}			
				$GLOBALS['debug']->log(' FIN Funcion COMANDO las sucursales');
			$this -> result = $branches;
		}
	}
?>